package com.zhaoxi.springboot.interceptor.springbootinterceptor.config;

import com.zhaoxi.springboot.interceptor.springbootinterceptor.interceptor.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 欢迎来到牧码人教育，做Java我们是专业的
 *
 * @创建人： 牧码人教育-Gerry
 * @创建时间： 2020-4-26
 * @功能描述： 配置拦截器
 */
@Configuration
public class MvcConfig extends WebMvcConfigurationSupport {
    public MvcConfig() {
        System.out.println("MvcConfig");
    }
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        // 设置的路径必须是绝对路径，否则拦截无效
        registry.addInterceptor(new UserInterceptor())
                .addPathPatterns("/v1/api/user/**")
                .excludePathPatterns("/v1/api/user/login");
    }
}
